//
//  RegistrationPhoneNumCellViewModel.swift
//  PorscheRegistration
//
//  Created by Jinzhu Liu on 2023/11/16.
//

import Foundation
import Combine

protocol RegistrationPhoneNumCellViewModelInputType: RegistrationTextFieldCellViewModelInputType {
    
}

protocol RegistrationPhoneNumCellViewModelOutputType: RegistrationTitleCellViewModelOutputType,
                                                      RegistrationTextFieldCellViewModelOutputType {
    
}

protocol RegistrationPhoneNumCellViewModelType: RegistrationCellViewModelType {
    var input: RegistrationPhoneNumCellViewModelInputType { get }
    var output: RegistrationPhoneNumCellViewModelOutputType { get }
}

class RegistrationPhoneNumCellViewModel: ObservableObject,
                                         RegistrationPhoneNumCellViewModelType,
                                         RegistrationPhoneNumCellViewModelInputType {
    @Published var textValue: String = ""
    
    var input: RegistrationPhoneNumCellViewModelInputType { self }
    var output: RegistrationPhoneNumCellViewModelOutputType { self }
    
    var title: String = "Phone Number"
    var textFieldEnable: Bool = true
}

extension RegistrationPhoneNumCellViewModel: RegistrationPhoneNumCellViewModelOutputType {
    var textValuePublisher: AnyPublisher<String, Never> {
        $textValue.eraseToAnyPublisher()
    }
}
